<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\service\fetch;

use app\service\fetch\kuaishou\ActionBarService;
use app\service\fetch\kuaishou\AdvCardService;
use app\service\fetch\kuaishou\AppService;
use app\service\fetch\kuaishou\AppSubPackageService;
use app\service\fetch\kuaishou\CampaignService;
use app\service\fetch\kuaishou\CreativeCategoryLabelService;
use app\service\fetch\kuaishou\CreativeCategoryLabelWhiteService;
use app\service\fetch\kuaishou\CreativeTagService;
use app\service\fetch\kuaishou\CreativeWordService;
use app\service\fetch\kuaishou\LibraryService;
use app\service\fetch\kuaishou\LpPageService;
use app\service\fetch\kuaishou\MongoPicAllService;
use app\service\fetch\kuaishou\MongoPicService;
use app\service\fetch\kuaishou\MongoVideoAllService;
use app\service\fetch\kuaishou\MongoVideoCreativeNumService;
use app\service\fetch\kuaishou\MongoVideoService;
use app\service\fetch\kuaishou\MongoVideoStatusDelService;
use app\service\fetch\kuaishou\MongoVideoUpdateAllService;
use app\service\fetch\kuaishou\NativeAuthService;
use app\service\fetch\kuaishou\NativeVideoService;
use app\service\fetch\kuaishou\OcpxConversionDeepTypesService;
use app\service\fetch\kuaishou\OcpxConversionOcpxTypesService;
use app\service\fetch\kuaishou\PicService;
use app\service\fetch\kuaishou\PlayableButtonsService;
use app\service\fetch\kuaishou\PlayableService;
use app\service\fetch\kuaishou\ProductService;
use app\service\fetch\kuaishou\TargetTemplateService;
use app\service\fetch\kuaishou\VideoAllService;
use app\service\fetch\kuaishou\VideoService;
use app\service\fetch\kuaishou\VideoStatusDelService;

class KuaiShouFetchService extends FetchService
{
    /**
     * 拉取应用.
     *
     * @param string $advertiserId 广告主id
     */
    public static function fetchAppList(string $advertiserId = ''): bool
    {
        $key = AppService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = AppService::getApp($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取定向模板.
     * @param string $advertiserId 账户id
     */
    public static function fetchTargetTemplate(string $advertiserId = ''): bool
    {
        $key = TargetTemplateService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = TargetTemplateService::getTargetTemplate($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取计划列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchCampaignList(string $advertiserId = ''): bool
    {
        $key = CampaignService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = CampaignService::getCampaign($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取图片素材列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchPicList(string $advertiserId = ''): bool
    {
        $key = PicService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = PicService::getPic($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取增量视频素材列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchVideoList(string $advertiserId = ''): bool
    {
        $key = VideoService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = VideoService::getVideo($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取全量视频素材列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchVideoAllList(string $advertiserId = ''): bool
    {
        $key = VideoAllService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = VideoAllService::getVideo($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取视频素材删除状态.
     * @param string $advertiserId 账户id
     */
    public static function fetchVideoDelStatus(string $advertiserId = ''): bool
    {
        $key = VideoStatusDelService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = VideoStatusDelService::getVideo($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取快手行动号召按钮列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchActionList(string $advertiserId = ''): bool
    {
        $key = ActionBarService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = ActionBarService::getAction($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取创意分类标签白名单客户列表.
     *
     * @param string $advertiserId 账户id
     */
    public static function fetchCreativeCategoryLabelWhiteList(string $advertiserId = ''): bool
    {
        $key = CreativeCategoryLabelWhiteService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = CreativeCategoryLabelWhiteService::getCreativeCategoryLabelWhite($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取创意分类标签白名单客户列表.
     * @param string $advertiserId 广告主id
     */
    public static function fetchCreativeCategoryLabelList(string $advertiserId = ''): bool
    {
        $key = CreativeCategoryLabelService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = CreativeCategoryLabelService::getCreativeCategoryLabel($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取创意标签填写建议.
     *
     * @param string $advertiserId 广告主id
     */
    public static function fetchCreativeTag(string $advertiserId = ''): bool
    {
        $key = CreativeTagService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = CreativeTagService::getCreativeTag($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取可选的动态词包.
     *
     * @param string $advertiserId 广告主id
     */
    public static function fetchCreativeWord(string $advertiserId = ''): bool
    {
        $key = CreativeWordService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = CreativeWordService::getCreativeWord($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取试玩.
     *
     * @param string $advertiserId 账户id
     */
    public static function fetchPlayable(string $advertiserId = ''): bool
    {
        $key = PlayableService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = PlayableService::getPlayable($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取试玩按钮列表.
     *
     * @param string $advertiserId 账户id
     */
    public static function fetchPlayableButtons(string $advertiserId = ''): bool
    {
        $key = PlayableButtonsService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = PlayableButtonsService::getPlayableButtons($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 获取可选的浅度优化目标.
     *
     * @param string $advertiserId 账户id
     */
    public static function fetchOcpxConversionOcpxTypes(string $advertiserId = ''): bool
    {
        $key = OcpxConversionOcpxTypesService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = OcpxConversionOcpxTypesService::getOcpxConversionOcpxTypes($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 获取可选的深度优化目标.
     *
     * @param string $advertiserId 账户id
     */
    public static function fetchOcpxConversionDeepTypes(string $advertiserId = ''): bool
    {
        $key = OcpxConversionDeepTypesService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = OcpxConversionDeepTypesService::getOcpxConversionDeepTypes($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 获取高级创意列表.
     *
     * @param string $advertiserId 账户id
     */
    public static function fetchAdvCard(string $advertiserId = ''): bool
    {
        $key = AdvCardService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = AdvCardService::getAdvCard($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 获取新版分包发布列表.
     *
     * @param string $advertiserId 账户id
     */
    public static function fetchAppSubPackage(string $advertiserId = ''): bool
    {
        $key = AdvCardService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = AppSubPackageService::getApp($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取快手号授权列表.
     *
     * @param string $advertiserId 广告主id
     */
    public static function fetchNativeAuthList(string $advertiserId = ''): bool
    {
        $key = AppService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = NativeAuthService::getNativeAuth($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取快手原生视频列表.
     *
     * @param string $advertiserId 广告主id
     */
    public static function fetchNativeVideoList(string $advertiserId = ''): bool
    {
        $key = AppService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = NativeVideoService::getNativeVideo($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取魔力建站落地页信息.
     *
     * @param string $advertiserId 广告主id
     */
    public static function fetchLpPageList(string $advertiserId = ''): bool
    {
        $key = AppService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = LpPageService::getLpPageList($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取mongo增量视频素材列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchMongoVideoList(string $advertiserId = ''): bool
    {
        $key = MongoVideoService::getFetchKey($advertiserId);

        if (self::lock($key, $advertiserId)) {
            $res = MongoVideoService::getVideo($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取mongo全量视频素材列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchMongoVideoAllList(string $advertiserId = ''): bool
    {
        $key = MongoVideoAllService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = MongoVideoAllService::getVideo($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取mongo视频素材关联创意数.
     * @param string $advertiserId 账户id
     */
    public static function fetchMongoVideoCreativeNum(string $advertiserId = ''): bool
    {
        $key = MongoVideoCreativeNumService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = MongoVideoCreativeNumService::getNum($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取mongo视频素材删除状态.
     * @param string $advertiserId 账户id
     */
    public static function fetchMongoVideoDelStatus(string $advertiserId = ''): bool
    {
        $key = MongoVideoStatusDelService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = MongoVideoStatusDelService::getVideo($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取增量图片列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchMongoPicList(string $advertiserId = ''): bool
    {
        $key = MongoPicService::getFetchKey($advertiserId);

        if (self::lock($key, $advertiserId)) {
            $res = MongoPicService::getPic($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取图片列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchMongoPicAllList(string $advertiserId = ''): bool
    {
        $key = MongoPicAllService::getFetchKey($advertiserId);

        if (self::lock($key, $advertiserId)) {
            $res = MongoPicAllService::getPic($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取商品库列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchLibraryList(string $advertiserId = ''): bool
    {
        $key = LibraryService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = LibraryService::getLibrary($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取商品列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchProductList(string $advertiserId = ''): bool
    {
        $key = ProductService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = ProductService::getProduct($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * 拉取mongo全量视频素材列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchMongoVideoUpdateAllList(string $advertiserId = ''): bool
    {
        $key = MongoVideoUpdateAllService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = MongoVideoUpdateAllService::getVideo($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }
}
